#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/StochasticProcess.h>
#pragma unmanaged 
#include <ql\processes\gjrgarchprocess.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Math;
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Processes {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IGJRGARCHProcess
	public ref class CGJRGARCHProcess  : 
            public CStochasticProcess,
            public Cephei::QL::Processes::IGJRGARCHProcess
	{
	protected: 
		boost::shared_ptr<QuantLib::GJRGARCHProcess>* _ppGJRGARCHProcess;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::GJRGARCHProcess>* _phGJRGARCHProcess;
#endif
		Object^ _GJRGARCHProcessOwner;     // reference to object that manages the storage for this object
	internal:
		CGJRGARCHProcess (Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeRate, Cephei::QL::Termstructures::IYieldTermStructure^ dividendYield, Cephei::QL::IQuote^ s0, Double v0, Double omega, Double alpha, Double beta, Double gamma, Double lambda, Microsoft::FSharp::Core::FSharpOption<Double>^ daysPerYear, Microsoft::FSharp::Core::FSharpOption<QL::Processes::GJRGARCHProcess::DiscretizationEnum>^ d);
        CGJRGARCHProcess (boost::shared_ptr<QuantLib::GJRGARCHProcess>& childNative, Object^ owner);
        CGJRGARCHProcess (QuantLib::GJRGARCHProcess& childNative, Object^ owner);
        CGJRGARCHProcess (CGJRGARCHProcess^ copy);
        CGJRGARCHProcess (PLATFORM::Type^ t);
#ifdef STRUCT
        CGJRGARCHProcess (QuantLib::GJRGARCHProcess childNative);
#endif       
#ifdef HANDLE
		CGJRGARCHProcess (QuantLib::Handle<QuantLib::GJRGARCHProcess>& childNative, Object^ owner);
		CGJRGARCHProcess (QuantLib::Handle<QuantLib::GJRGARCHProcess> childNative);
#endif
		virtual ~CGJRGARCHProcess ();
		!CGJRGARCHProcess ();

	internal:
		QuantLib::GJRGARCHProcess& GetReference ();
		boost::shared_ptr<QuantLib::GJRGARCHProcess>& GetShared ();
		QuantLib::GJRGARCHProcess* GetPointer ();
        void SetGJRGARCHProcess (boost::shared_ptr<QuantLib::GJRGARCHProcess> native)
        {
            if (_ppGJRGARCHProcess != NULL)
                delete _ppGJRGARCHProcess;
            _ppGJRGARCHProcess = new boost::shared_ptr<QuantLib::GJRGARCHProcess> (native);
            SetStochasticProcess (boost::dynamic_pointer_cast<QuantLib::StochasticProcess> (*_ppGJRGARCHProcess));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::GJRGARCHProcess>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Double Alpha 
        {
		    virtual Double get () ;
        }
        property Double Beta 
        {
		    virtual Double get () ;
        }
        property Double DaysPerYear 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Termstructures::IYieldTermStructure^ DividendYield 
        {
		    virtual Cephei::QL::Termstructures::IYieldTermStructure^ get () ;
        }
        property Double Gamma 
        {
		    virtual Double get () ;
        }
        property Double Lambda 
        {
		    virtual Double get () ;
        }
        property Double Omega 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Termstructures::IYieldTermStructure^ RiskFreeRate 
        {
		    virtual Cephei::QL::Termstructures::IYieldTermStructure^ get () ;
        }
        property Cephei::QL::IQuote^ S0 
        {
		    virtual Cephei::QL::IQuote^ get () ;
        }
        property UInt64 Size 
        {
		    virtual UInt64 get () ;
        }
		virtual Double Time (DateTime d) ;
        property Double V0 
        {
		    virtual Double get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Processes::IGJRGARCHProcess^>::typeid)]
	[FactoryFor(Cephei::QL::Processes::IGJRGARCHProcess::typeid)]
	[FactoryFor(Cephei::QL::Processes::IGJRGARCHProcess_Factory::typeid)]
	public ref class CGJRGARCHProcess_Factory sealed : public IGJRGARCHProcess_Factory
	{
	public:
        virtual IGJRGARCHProcess^ Create (Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeRate, Cephei::QL::Termstructures::IYieldTermStructure^ dividendYield, Cephei::QL::IQuote^ s0, Double v0, Double omega, Double alpha, Double beta, Double gamma, Double lambda, Microsoft::FSharp::Core::FSharpOption<Double>^ daysPerYear, Microsoft::FSharp::Core::FSharpOption<QL::Processes::GJRGARCHProcess::DiscretizationEnum>^ d);
    };
   
/*Cephei*/ } /*QL*/ } /*Processes */}
